package bamin.com.bamindaijia.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import bamin.com.bamindaijia.R;
import bamin.com.bamindaijia.model.Order;

public class MyOrderAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<Order> mDatas;


    class ViewHolder {
        TextView mTv_time;
        TextView mTv_state;
        TextView mTv_start;
        TextView mTv_end;
        TextView mTv_price;
    }

    public MyOrderAdapter(Context context, List<Order> mDatas) {

        inflater = LayoutInflater.from(context);

        this.mDatas = mDatas;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_order_info, null);
            holder.mTv_time = (TextView) convertView.findViewById(R.id.textView_time);
            holder.mTv_state = (TextView) convertView.findViewById(R.id.textView_OrderState);
            holder.mTv_start = (TextView) convertView.findViewById(R.id.textView_start);
            holder.mTv_end = (TextView) convertView.findViewById(R.id.textView_end);
            holder.mTv_price = (TextView) convertView.findViewById(R.id.textView_price);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        Order datasBean = mDatas.get(position);
        holder.mTv_time.setText("下单时间：" + datasBean.getOrderTime());
        holder.mTv_state.setText("订单状态：" + datasBean.getOrderStatus());
        holder.mTv_start.setText(datasBean.getStartLocation());
        holder.mTv_end.setText(datasBean.getEndLocation());

//            if (datasBean.getFinalPrice() != null) {
//                holder.mTv_price.setVisibility(View.VISIBLE);
//                holder.mTv_price.setText("" + datasBean.getFinalPrice() + "元");
//            } else {
//                holder.mTv_price.setVisibility(View.GONE);
//            }


        return convertView;
    }



}